package com.lagou.studentsystem.service.impl;

import com.lagou.studentsystem.dao.StudentDao;
import com.lagou.studentsystem.factory.StudentDaoFactory;
import com.lagou.studentsystem.model.Student;
import com.lagou.studentsystem.service.StudentService;

import java.util.List;

public class StudentServiceImpl implements StudentService {

    private StudentDao studentDao;

    public StudentServiceImpl() {
        this.studentDao = StudentDaoFactory.getStudentDao();
    }

    @Override
    public List<Student> getStudentAll() {
        return studentDao.getStudentAll();
    }

    @Override
    public int saveStudent(Student student) {
        return studentDao.insertStudent(student);
    }

    @Override
    public int removeStudentById(String id) {
        return studentDao.deleteStudentById(id);
    }

    @Override
    public int updateStudentById(String id, Student student) {

        return studentDao.updateStudentById(id,student);
    }

    @Override
    public Student getStudentById(String id) {
        return studentDao.getStudentById(id);
    }

    @Override
    public List<Student> getStudentByName(String name) {
        return studentDao.getStudentByName(name);
    }
}
